package com.aisile;



import java.io.*;
import java.util.Base64;

/**
 * @Auther:yry
 * @Date:2023/12/26 0026
 * @VERSON:1.0
 */
public class utils {
    public static void main(String[] args) {
        File file = new File("C:\\Users\\YangRenyu\\Pictures\\fastDFS测试\\王东镇.jpg");
        try (FileInputStream fis = new FileInputStream(file);
             ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
            byte[] buffer = new byte[1024];
            int bytesRead;
            while ((bytesRead = fis.read(buffer)) != -1) {
                bos.write(buffer, 0, bytesRead);
            }
            byte[] imageBytes = bos.toByteArray();
            String url = Base64.getEncoder().encodeToString(imageBytes);
            System.out.println(url);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
